home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir31 / tnypl211.zip / EX1B.ASM < prev    next >
Assembly Source File  |  1994-06-21  |  6KB  |  242 lines

  1. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2. ; lbm.asm - IFF/ILBM decoder for VGA 640x480x16 graphics mode
  3. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  4.  
  5. ideal
  6. p386
  7. model   flat,c
  8.  
  9. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  10. ; PUBLICS
  11. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  12.  
  13. global  putlbm:proc
  14.  
  15. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  16. ; EQUATES AND STRUCTURES
  17. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  18.  
  19. ID_FORM         = 4D524F46h             ; IFF/ILBM chunk IDs
  20. ID_ILBM         = 4D424C49h
  21. ID_BMHD         = 44484D42h
  22. ID_CMAP         = 50414D43h
  23. ID_BODY         = 59444F42h
  24.  
  25. struc   Form                            ; IFF/ILBM header file format
  26.   ID            dd      ?
  27.   Length        dd      ?
  28.   Type          dd      ?
  29. ends    Form
  30.  
  31. struc   Chunk                           ; IFF/ILBM header chunk format
  32.   ID            dd      ?
  33.   Length        dd      ?
  34. ends    Chunk
  35.  
  36. struc   BMHD                            ; IFF/ILBM BMHD chunk format
  37.   Width         dw      ?
  38.   Height        dw      ?
  39.   PosX          dw      ?
  40.   PosY          dw      ?
  41.   Planes        db      ?
  42.   Masking       db      ?
  43.   Compression   db      ?
  44.   Pad           db      ?
  45.   Transparent   dw      ?
  46.   AspectX       db      ?
  47.   AspectY       db      ?
  48.   PageWidth     dw      ?
  49.   PageHeight    dw      ?
  50. ends    BMHD
  51.  
  52. struc   CMAP                            ; IFF/ILBM CMAP chunk format
  53.   Colors        db      768 dup (?)
  54. ends    CMAP
  55.  
  56. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  57. ; DATA
  58. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  59. dataseg
  60.  
  61. width   dd      ?                       ; current picture width and height
  62. height  dd      ?
  63.  
  64. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  65. ; CODE
  66. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  67. codeseg
  68.  
  69. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  70. ; bswap - macro to reverse the byte order of a 32-bit register, converting
  71. ;         a value in little/big endian form to big/little endian form.
  72. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  73. macro   bswap   reg
  74.         xchg    al,ah
  75.         rol     eax,16
  76.         xchg    al,ah
  77. endm
  78.  
  79. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  80. ; putlbm - draw the IFF/ILBM picture on VGA 640x480x16 graphics mode
  81. ; In:
  82. ;  ESI = IFF/ILBM image file address
  83. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  84. putlbm:
  85.         pushad
  86.  
  87. ; check if this is a valid IFF/ILBM Deluxe Paint file
  88.  
  89.         cmp     [esi+Form.ID],ID_FORM
  90.         jne     putlbmd0
  91.         cmp     [esi+Form.Type],ID_ILBM
  92.         jne     putlbmd0
  93.  
  94. ; get the IFF/ILBM file length in bytes
  95.  
  96.         mov     eax,[esi+Form.Length]
  97.         bswap   eax
  98.         mov     ecx,eax
  99.  
  100. ; decrease the file length and updates the file pointer
  101.  
  102.         sub     ecx,4
  103.         add     esi,size Form
  104.  
  105. ; IFF/ILBM main parser body loop
  106.  
  107. putlbml0:
  108.         test    ecx,ecx
  109.         jle     putlbmd1
  110.  
  111. ; get the next chunk ID and length in bytes
  112.  
  113.         mov     ebx,[esi+Chunk.ID]
  114.         mov     eax,[esi+Chunk.Length]
  115.         bswap   eax
  116.         xchg    ebx,eax
  117.         add     esi,size Chunk
  118.  
  119. ; word align the chunk length and decrease the file length counter
  120.  
  121.         inc     ebx
  122.         and     bl,not 1
  123.         sub     ecx,size Chunk
  124.         sub     ecx,ebx
  125.  
  126. ; check for the BMHD/CMAP/BODY chunk headers
  127.  
  128.         cmp     eax,ID_BMHD
  129.         je      putlbmf0
  130.         cmp     eax,ID_CMAP
  131.         je      putlbmf1
  132.         cmp     eax,ID_BODY
  133.         je      putlbmf2
  134.  
  135. ; advance to the next IFF/ILBM chunk structure
  136.  
  137. putlbmc0:
  138.         add     esi,ebx
  139.         jmp     putlbml0
  140.  
  141. ; process the BMHD bitmap header chunk
  142.  
  143. putlbmf0:
  144.         cmp     [esi+BMHD.Planes],4
  145.         jne     putlbmd0
  146.         cmp     [esi+BMHD.Compression],1
  147.         jne     putlbmd0
  148.         cmp     [esi+BMHD.Pad],0
  149.         jne     putlbmd0
  150.         movzx   eax,[esi+BMHD.Width]
  151.         xchg    al,ah
  152.         add     eax,7
  153.         shr     eax,3
  154.         mov     [width],eax
  155.         movzx   eax,[esi+BMHD.Height]
  156.         xchg    al,ah
  157.         mov     [height],eax
  158.         jmp     putlbmc0
  159.  
  160. ; process the CMAP colormap chunk
  161.  
  162. putlbmf1:
  163.         mov     dx,3C8h
  164.         xor     al,al
  165.         out     dx,al
  166.         inc     dx
  167. putlbml1:
  168.         mov     al,[esi]
  169.         shr     al,2
  170.         out     dx,al
  171.         inc     esi
  172.         dec     ebx
  173.         jg      putlbml1
  174.         jmp     putlbml0
  175.  
  176. ; process the BODY bitmap body chunk
  177.  
  178. putlbmf2:
  179.         pushad
  180.         push    es
  181.         mov     ax,ds
  182.         mov     es,ax
  183.         mov     edi,0A0000h
  184.         cld
  185.         mov     dx,3CEh
  186.         mov     ax,0FF08h
  187.         out     dx,ax
  188.         mov     dx,3C4h
  189.         mov     al,02h
  190.         out     dx,al
  191.         inc     dx
  192.         mov     ecx,[height]
  193. putlbml2:
  194.         push    ecx
  195.         mov     al,11h
  196. putlbml3:
  197.         push    eax
  198.         push    edi
  199.         out     dx,al
  200.         mov     ebx,[width]
  201. putlbml4:
  202.         lodsb
  203.         test    al,al
  204.         jl      putlbmf3
  205.         movzx   ecx,al
  206.         inc     ecx
  207.         sub     ebx,ecx
  208.         rep     movsb
  209.         jmp     putlbmc4
  210. putlbmf3:
  211.         neg     al
  212.         movzx   ecx,al
  213.         inc     ecx
  214.         sub     ebx,ecx
  215.         lodsb
  216.         rep     stosb
  217. putlbmc4:
  218.         test    ebx,ebx
  219.         jg      putlbml4
  220.         pop     edi
  221.         pop     eax
  222.         add     al,al
  223.         jnc     putlbml3
  224.         add     edi,80
  225.         pop     ecx
  226.         loop    putlbml2
  227.         pop     es
  228.         popad
  229.         jmp     putlbmc0
  230.  
  231. putlbmd1:
  232.         clc
  233.         popad
  234.         ret
  235. putlbmd0:
  236.         stc
  237.         popad
  238.         ret
  239.  
  240. end
  241.  
  242.